home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / C++ A'Link Files / 1989 / 0028-?Overloading the new-Dec89 < prev    next >
Encoding:
Text File  |  1991-03-06  |  1.4 KB  |  54 lines  |  [TEXT/GEOL]

  1. Item forwarded  by  ALCABES      to CPLUS.APPLE$
  2.  
  3. Item    6591703                         24-Dec-89        05:09
  4.  
  5. From:   MADA.EUROPE                     MacApp Dev Assoc Europe, E Carrasco
  6.  
  7. To:     CPLUS.DEV$                      C++ Interest List--Developers
  8.  
  9. Sub:    ?Overloading the new operator
  10.  
  11. Attn:  C++ developers
  12.        ⁄ CPlus.Dev$
  13.  
  14. From:  Vincent Hoffmann
  15.        Gimeor
  16.        ⁄ MADA.Europe
  17.  
  18. Sub:   Overloading the new operator.
  19.  
  20. Hi all,
  21. We are learning MacApp and C++ at MADA Europe trainings.
  22. We want a lot of Graphic Segments on screen and don't want to use Pascal
  23. Objects (Handles). We need to overload the operators new and delete to allocate
  24. our objects (and their fields) in memory.
  25.  
  26. /* Is this interface correct? */
  27.   Class TGraphicSegment {       // a PointerObject
  28.       private:
  29.          long   fSize
  30.          long   fAddress
  31.          /* ... */
  32.       public:
  33.          void* operator new(long logicalSize)
  34.          void* TGraphicSegment::operator delete(void* space)
  35.          /* ... */
  36.       };
  37.  
  38.  
  39. /* Implementation */
  40.       void* TGraphicSegment::operator new(size_t logicalSize) {
  41.          /* ... */
  42.          return aSeg;
  43.       };
  44.  
  45. How could we implements the new operator? Objects and their fields have to be
  46. places in a specific location in our heap (a big block allocated at the
  47. beginning of the application). Each object knows its size, location, and other
  48. properties.
  49.  
  50.  
  51. Thanks for your help
  52. Yves
  53.  
  54.